package com.zenchn.dynamic;

import static com.zenchn.dynamic.TMiCustomerTransferDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import com.zenchn.model.TMiCustomerTransfer;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.insert.render.MultiRowInsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface TMiCustomerTransferDynamicMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    BasicColumn[] selectList = BasicColumn.columnList(transferId, customerId, beforeAccountId, afterAccountId, isEnable, creator, createTime);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<TMiCustomerTransfer> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    @InsertProvider(type=SqlProviderAdapter.class, method="insertMultiple")
    int insertMultiple(MultiRowInsertStatementProvider<TMiCustomerTransfer> multipleInsertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("TMiCustomerTransferResult")
    Optional<TMiCustomerTransfer> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="TMiCustomerTransferResult", value = {
        @Result(column="transfer_id", property="transferId", jdbcType=JdbcType.CHAR, id=true),
        @Result(column="customer_id", property="customerId", jdbcType=JdbcType.CHAR),
        @Result(column="before_account_id", property="beforeAccountId", jdbcType=JdbcType.CHAR),
        @Result(column="after_account_id", property="afterAccountId", jdbcType=JdbcType.CHAR),
        @Result(column="is_enable", property="isEnable", jdbcType=JdbcType.CHAR),
        @Result(column="creator", property="creator", jdbcType=JdbcType.CHAR),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP)
    })
    List<TMiCustomerTransfer> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, TMiCustomerTransfer, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, TMiCustomerTransfer, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    default int deleteByPrimaryKey(String transferId_) {
        return delete(c -> 
            c.where(transferId, isEqualTo(transferId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    default int insert(TMiCustomerTransfer record) {
        return MyBatis3Utils.insert(this::insert, record, TMiCustomerTransfer, c ->
            c.map(transferId).toProperty("transferId")
            .map(customerId).toProperty("customerId")
            .map(beforeAccountId).toProperty("beforeAccountId")
            .map(afterAccountId).toProperty("afterAccountId")
            .map(isEnable).toProperty("isEnable")
            .map(creator).toProperty("creator")
            .map(createTime).toProperty("createTime")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    default int insertMultiple(Collection<TMiCustomerTransfer> records) {
        return MyBatis3Utils.insertMultiple(this::insertMultiple, records, TMiCustomerTransfer, c ->
            c.map(transferId).toProperty("transferId")
            .map(customerId).toProperty("customerId")
            .map(beforeAccountId).toProperty("beforeAccountId")
            .map(afterAccountId).toProperty("afterAccountId")
            .map(isEnable).toProperty("isEnable")
            .map(creator).toProperty("creator")
            .map(createTime).toProperty("createTime")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    default int insertSelective(TMiCustomerTransfer record) {
        return MyBatis3Utils.insert(this::insert, record, TMiCustomerTransfer, c ->
            c.map(transferId).toPropertyWhenPresent("transferId", record::getTransferId)
            .map(customerId).toPropertyWhenPresent("customerId", record::getCustomerId)
            .map(beforeAccountId).toPropertyWhenPresent("beforeAccountId", record::getBeforeAccountId)
            .map(afterAccountId).toPropertyWhenPresent("afterAccountId", record::getAfterAccountId)
            .map(isEnable).toPropertyWhenPresent("isEnable", record::getIsEnable)
            .map(creator).toPropertyWhenPresent("creator", record::getCreator)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    default Optional<TMiCustomerTransfer> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, TMiCustomerTransfer, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    default List<TMiCustomerTransfer> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, TMiCustomerTransfer, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    default List<TMiCustomerTransfer> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, TMiCustomerTransfer, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    default Optional<TMiCustomerTransfer> selectByPrimaryKey(String transferId_) {
        return selectOne(c ->
            c.where(transferId, isEqualTo(transferId_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, TMiCustomerTransfer, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    static UpdateDSL<UpdateModel> updateAllColumns(TMiCustomerTransfer record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(transferId).equalTo(record::getTransferId)
                .set(customerId).equalTo(record::getCustomerId)
                .set(beforeAccountId).equalTo(record::getBeforeAccountId)
                .set(afterAccountId).equalTo(record::getAfterAccountId)
                .set(isEnable).equalTo(record::getIsEnable)
                .set(creator).equalTo(record::getCreator)
                .set(createTime).equalTo(record::getCreateTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(TMiCustomerTransfer record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(transferId).equalToWhenPresent(record::getTransferId)
                .set(customerId).equalToWhenPresent(record::getCustomerId)
                .set(beforeAccountId).equalToWhenPresent(record::getBeforeAccountId)
                .set(afterAccountId).equalToWhenPresent(record::getAfterAccountId)
                .set(isEnable).equalToWhenPresent(record::getIsEnable)
                .set(creator).equalToWhenPresent(record::getCreator)
                .set(createTime).equalToWhenPresent(record::getCreateTime);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    default int updateByPrimaryKey(TMiCustomerTransfer record) {
        return update(c ->
            c.set(customerId).equalTo(record::getCustomerId)
            .set(beforeAccountId).equalTo(record::getBeforeAccountId)
            .set(afterAccountId).equalTo(record::getAfterAccountId)
            .set(isEnable).equalTo(record::getIsEnable)
            .set(creator).equalTo(record::getCreator)
            .set(createTime).equalTo(record::getCreateTime)
            .where(transferId, isEqualTo(record::getTransferId))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", comments="Source Table: t_mi_customer_transfer")
    default int updateByPrimaryKeySelective(TMiCustomerTransfer record) {
        return update(c ->
            c.set(customerId).equalToWhenPresent(record::getCustomerId)
            .set(beforeAccountId).equalToWhenPresent(record::getBeforeAccountId)
            .set(afterAccountId).equalToWhenPresent(record::getAfterAccountId)
            .set(isEnable).equalToWhenPresent(record::getIsEnable)
            .set(creator).equalToWhenPresent(record::getCreator)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .where(transferId, isEqualTo(record::getTransferId))
        );
    }
}